from django.contrib.auth.models import User
import datetime
from DjangoSite.burndown.models import GraphData
import random

def pseudogen():
    p1, p2, p3, p4 = User.objects.all()
    startdate = datetime.date(2009, 9, 17)
    today = datetime.date(2010, 9, 17)
    oneday = datetime.timedelta(days=1)
    
    p1c = 26
    p2c = 25
    p3c = 24
    p4c = 29
    
    p1t = 1300
    p2t = 1100
    p3t = 1200
    p4t = 1400
    
    p1e = True
    p2e = True
    p3e = True
    p4e = True
    
    GraphData(person=p1, date=startdate, taskcount=p1c, timecount=p1t).save()
    GraphData(person=p2, date=startdate, taskcount=p2c, timecount=p2t).save()
    GraphData(person=p3, date=startdate, taskcount=p3c, timecount=p3t).save()
    GraphData(person=p4, date=startdate, taskcount=p4c, timecount=p4t).save()
    
    while startdate < today:
        startdate = startdate + oneday
        
        if (p1e): p1c = p1c - random.choice((0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, 1, 1, 1))
        if (p2e): p2c = p2c - random.choice((0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, 1, 1, 1))
        if (p3e): p3c = p3c - random.choice((0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, 1, 1, 1))
        if (p4e): p4c = p4c - random.choice((0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, 1, 1, 1))
        
        if (p1e): p1t = p1t - random.choice((8, 8, 7, 7, 7, 6, 6, 5, 4, 3, 2, 1, -3, -12))
        if (p2e): p2t = p2t - random.choice((8, 7, 7, 7, 6, 6, 5, 4, 3, 2, 1, -1, -5, -10))
        if (p3e): p3t = p3t - random.choice((12, 11, 9, 7, 7, 6, 6, 5, 4, 1, -3, -9, -15))
        if (p4e): p4t = p4t - random.choice((9, 9, 9, 8, 8, 7, 6, 6, 5, 5, 5, 0, -4))
        
        if (p1c == 0 and p1t > 0):
            p1c = 1
        if (p2c == 0 and p2t > 0):
            p2c = 1
        if (p3c == 0 and p3t > 0):
            p3c = 1
        if (p4c == 0 and p4t > 0):
            p4c = 1
            
        if (p1t <= 0):
            p1c = 0
            p1t = 0
            p1e = False
        
        if (p2t <= 0):
            p2c = 0
            p2t = 0
            p2e = False
        
        if (p3t <= 0):
            p3c = 0
            p3t = 0
            p3e = False
        
        if (p4t <= 0):
            p4c = 0
            p4t = 0
            p4e = False
        
        GraphData(person=p1, date=startdate, taskcount=p1c, timecount=p1t).save()
        GraphData(person=p2, date=startdate, taskcount=p2c, timecount=p2t).save()
        GraphData(person=p3, date=startdate, taskcount=p3c, timecount=p3t).save()
        GraphData(person=p4, date=startdate, taskcount=p4c, timecount=p4t).save()
